/*******************************************************************************
 * Author  : Son Hua
 * Date    : 2009-09-02 
 ******************************************************************************/

#ifndef _RENZO_INPUT_
#define _RENZO_INPUT_

#include "RenzoNesMustHave.h"

/*
@description
Input class loads a ROM file into memory and serves as a ROM content provider to CPU.
In NES, Input reads the whole ROM into the memory.

This class serves as the instruction fetch (IF) stage in the pipeline. 
Since instructions of 6502 CPU is encoded as fixed length (1 byte), it is easy to decode.
*/
namespace Renzo {
class Input
{
public:
	Input(const char* file);
	~Input(void);

	byte nextByte();
	bool hasNext();

private:
	FILE* f;
	int size;		// file size, in bytes
	byte* buffer;	// content of the file
	byte* pBuf;	// current position of the data pointer (used for data visit)
};
}

#endif